<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="util.Constant, db.DBMain, java.util.HashMap, java.util.Set,
			db.DBInterface" %>

<%  
	if(request.getParameter("freundadden") != null) {
		String target = request.getParameter(Constant.TARGET);
		Long target_id = Long.parseLong(target);
		Long user_id = (Long)session.getAttribute(Constant.USERID);
		String categorystring = request.getParameter("select");
		Long category = Long.parseLong(categorystring);
		DBInterface.addFriend(user_id, target_id, category);
	}

	if(request.getParameter(Constant.TARGET) != null) { 
	String target = request.getParameter(Constant.TARGET);
	Long target_id = Long.parseLong(target);
	String targetname = DBInterface.getCurrentUserName(target_id);%>
	<p align="center">Folgende Person wollen sie in ihre Freundesliste
		aufnehmen <%=targetname %>
	<form name="formfriend" method="get" action="./index.jsp">
	<p align="center">Ihre Beziehung zur Person festlegen:
    <label>
  		<select name="select">
  		<% HashMap<Long, String> beziehung = 
  			DBMain.getCategoryTable().getCategories(Constant.Type.CONTACT); 
  			Set<Long> keys = beziehung.keySet();
  			for (Long key : keys) { %>
 				 <option value="<%= key %>"></option>
  			<% }%>
  		</select>
  		</label>       
    </p>
  <p align="center"> 
  	<input type="hidden" name="<%=Constant.TARGET%>" value="<%=target_id%>">
    <input type="submit" name="freundadden" value="Freund hinzufuegen!">
  </p>
  </form>
<% } %>	
